package com.chanzany.factory.simpleFactory;

public class Client {
    public static void main(String[] args) {
        order("greek");
    }
    public static void order(String orderType) {
        Pizza pizza;
        switch (orderType) {
            case "greek":
                pizza = new GreekPizza();
                pizza.setName(" 希腊披萨 ");
                break;
            case "cheese":
                pizza = new CheesePizza();
                pizza.setName(" 奶酪披萨 ");
                break;
            case "pepper":
                pizza = new PepperPizza();
                pizza.setName("胡椒披萨");
                break;
            default:
                throw new RuntimeException("no this type");
        }
        //输出pizza 制作过程
        pizza.prepare();
        pizza.bake();
        pizza.cut();
        pizza.box();
    }
}


abstract class Pizza {
    protected String name;
    public abstract void prepare();
    public void bake() {
        System.out.println(name + " baking;");
    }
    public void cut() {
        System.out.println(name + " cutting;");
    }
    public void box() {
        System.out.println(name + " boxing;");
    }
    public void setName(String name) {
        this.name = name;
    }
}
class CheesePizza extends Pizza {
    @Override
    public void prepare() {
        System.out.println(name + " preparing;");
    }
}
class GreekPizza extends Pizza {
    @Override
    public void prepare() {
        System.out.println(name + " preparing;");
    }
}
class PepperPizza extends Pizza {
    @Override
    public void prepare() {
        System.out.println(name + " preparing;");
    }
}
